package com.wws.family.db.dao

import androidx.room.Dao
import androidx.room.Query
import com.wws.family.db.AccountBean

/**
 *@Description: 账本数据Dao
 *@Date: 2024/11/04 14:06
 *@Author: WangWeiShuo
 */
@Dao
interface AccountDao: BaseDao<AccountBean> {

    @Query("select * from db_account")
    fun getAccountInfo(): MutableList<AccountBean>

    @Query("select * from db_account where type = :type")
    fun getAccountInfoByType(type: Int): MutableList<AccountBean>

    @Query("select * from db_account where type = :type and year = :year and month = :month")
    fun getAccountInfoByTypeYear(type: Int,year: Int,month : Int): MutableList<AccountBean>

    @Query("select round(sum(price),2) from db_account where type = :type and year = :year and month = :month")
    fun getAccountPrice(type: Int,year: Int,month : Int): Double

    @Query("delete from db_account")
    fun deleteAll()

    @Query("delete from db_account where name = :name")
    fun deleteByName(name: String)

    @Query("delete from db_account where accountKey = :accountKey")
    fun deleteByKey(accountKey: Long)
}